<?php

/**
 * This is the model class for table "{{search}}".
 *
 * The followings are the available columns in table '{{search}}':
 * @property integer $zs_id
 * @property string $zs_type
 * @property integer $zs_infoid
 * @property string $zs_data
 * @property integer $inputtime
 * @property integer $updatetime
 */
class Search extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Search the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{search}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zs_infoid, inputtime, updatetime', 'numerical', 'integerOnly'=>true),
			array('zs_type', 'length', 'max'=>7),
			array('zs_data', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zs_id, zs_type, zs_infoid, zs_data, inputtime, updatetime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zs_id' => 'Zs',
			'zs_type' => 'Zs Type',
			'zs_infoid' => 'Zs Infoid',
			'zs_data' => 'Zs Data',
			'inputtime' => 'Inputtime',
			'updatetime' => 'Updatetime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zs_id',$this->zs_id);
		$criteria->compare('zs_type',$this->zs_type,true);
		$criteria->compare('zs_infoid',$this->zs_infoid);
		$criteria->compare('zs_data',$this->zs_data,true);
		$criteria->compare('inputtime',$this->inputtime);
		$criteria->compare('updatetime',$this->updatetime);

		$criteria->order = " inputtime DESC ";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}